<template>
    <div :class="[styleSeed.item, classNames.root, attrs.class]" :style="{ ...style, ...styles.root }" v-bind="attrs">
        <div v-if="icon || label" :class="[styleSeed.head, classNames.head]" :style="styles.head">
            <span v-if="icon" :class="[styleSeed.icon, classNames.icon]" :style="styles.icon">
                {{ icon }}
            </span>
            <span v-if="label" :class="[styleSeed.label, classNames.label]" :style="styles.label">
                {{ label }}
            </span>
            <span v-if="label && symbol" :class="[styleSeed.symbol, classNames.symbol]" :style="styles.symbol">
                {{ symbol }}
            </span>
        </div>
        <div :class="[styleSeed.body, classNames.body]" :style="styles.body">
            <slot>{{ value }}</slot>
        </div>
    </div>
</template>


<script setup>
import { useAttrs } from 'vue'
import StyleSeed from './style-seed'

const props = defineProps({
    classNames: {
        type: Object,
        default: () => ({})
    },
    styleSeed: {
        type: Object,
        default: StyleSeed.DEFAULT
    },
    icon: null,
    label: String,
    value: null,
    symbol: {
        type: String,
        default: ':'
    },
    style: null,
    styles: {
        type: Object,
        default: () => ({})
    }
})

const attrs = useAttrs()
</script>


<style lang="less">
//详情数据样式
.data-item {
  display: flex;
  color: var(--color-text, #393939);
  font-size: 14px;

  &-wrap {
    flex-direction: column;
  }

  &-head {
    box-sizing: border-box;
    min-width: var(--size-label-min-width, auto);
    padding: var(--size-cell-gap-min, 4px);
    padding-right: 0;
    color: var(--color-text-heading, #03255c);
    text-align: var(--align-label, left);
    box-sizing: border-box;
  }

  &-body {
    padding: var(--size-cell-gap-min, 4px);
    word-break: break-word;
  }

  &-icon {
    margin-right: 4px;
  }

  &-label {
    white-space: nowrap;
    margin-right: 4px;
  }

  &-symbol {
    // margin-left: 4px;
    font-weight: bold;
  }
}

.data-item-detail-simple {
  flex-direction: column;

  &-head {
    padding: 0;
  }

  &-body {
    padding: 0;
  }

  &-label {
    font-size: 12px;
  }

  &-symbol {
    display: none;
  }
}

// 统计卡片样式
.data-item-count {
  border-radius: var(--size-border-radius-lg, 8px);
  padding: var(--size-cell-gap, 16px);
  background-color: currentColor;

  &-head {
    display: flex;
    flex-direction: column;
  }

  &-body {
    color: #fff;
    line-height: 36px;
    font-size: 36px;
    font-weight: bold;
    transform: translateY(-28px);
  }

  &-icon {
    width: 60px;
    height: 60px;
    line-height: 60px;
    text-align: center;
    box-sizing: border-box;
    border-radius: var(--size-border-radius-lg, 8px);
    background-color: #fff;
    color: currentColor;
    font-size: 36px;
    margin-bottom: 28px;
  }

  &-label {
    font-size: 16px;
    color: #fff;
    transform: translateY(36px);
  }

  &-symbol {
    display: none;
  }
}

</style>
